package tau_sadna.tau_map;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.view.ViewPager.LayoutParams;
import android.util.Log;
import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;

/**
 * 
 * A transparent view filling the parent. Useful to capture clicks that
 * don't belong to any view.
 */
public class GlassView extends View {

	private boolean enabled = false;

	Context cont;
	
	public GlassView(Context context) {
		super(context);
		setBackgroundColor(Color.TRANSPARENT);
		RelativeLayout.LayoutParams fillParent = new RelativeLayout.LayoutParams(
				LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
		setLayoutParams(fillParent);
		this.cont = context;
	}
	
	@Override
	public void setOnClickListener(OnClickListener l) {
		if (l == null)
			enabled = false;  //We shouldn't capture clicks
		else
			enabled = true;
		super.setOnClickListener(l);
	}
	
	@Override
	public boolean dispatchTouchEvent(MotionEvent event) {
		if (enabled)
			return super.dispatchTouchEvent(event);
		return false;  //pass event to view below
	}
}
